/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    var ALL_ROWS = 100;
    vc.extends({
        data: {
            roleShopInfo: {
                roleShops: [],
                total: 0,
                records: 1,
                moreCondition: false,
                pgId: ''
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('roleShopInfo', 'openRoleShop', function (_param) {
                vc.copyObject(_param, $that.roleShopInfo);
                $that._listRoleShops(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('roleShopInfo', 'listRoleShop', function (_param) {
                //vc.copyObject(_param, $that.roleShopInfo.conditions);
                $that._listRoleShops(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('roleShopInfo', 'paginationPlus', 'page_event', function (_currentPage) {
                $that._listRoleShops(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listRoleShops: function (_page, _rows) {
                var param = {
                    params: {
                        page: _page,
                        row: _rows,
                        roleId: $that.roleShopInfo.pgId
                    }
                };
                //发送get请求
                vc.http.apiGet('/roleShop.listRoleShop',
                    param,
                    function (json, res) {
                        var _roleShopInfo = JSON.parse(json);
                        $that.roleShopInfo.total = _roleShopInfo.total;
                        $that.roleShopInfo.records = _roleShopInfo.records;
                        $that.roleShopInfo.roleShops = _roleShopInfo.data;
                        vc.emit('roleShopInfo', 'paginationPlus', 'init', {
                            total: $that.roleShopInfo.records,
                            dataCount: $that.roleShopInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddRoleShopModal: function () {
                vc.emit('addRoleShop', 'openAddRoleShopModal', {
                    roleId: $that.roleShopInfo.pgId,
                    orgName: $that.roleShopInfo.orgName
                });
            },
            _openDeleteRoleShopModel: function (_roleShop) {
                vc.emit('deleteRoleShop', 'openDeleteRoleShopModal', _roleShop);
            },
            _openBeyondRoleShop: function (_roleShop) {
            },
            _queryRoleShopMethod: function () {
                $that._listRoleShops(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.roleShopInfo.moreCondition) {
                    $that.roleShopInfo.moreCondition = false;
                } else {
                    $that.roleShopInfo.moreCondition = true;
                }
            },
            _goBack: function () {
                vc.emit('orgManage', 'onBack', {});
            }
        }
    });
})(window.vc);
